import { createStore, applyMiddleware } from 'redux'
import { persistStore, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'
// !#1 配置中间件第一步导入
import thunk from 'redux-thunk'
import rootReducer from './reducers'
const persistConfig = {
  key: '@_@',
  storage,
}
const persistedReducer = persistReducer(persistConfig, rootReducer)
// !#2 通过 createStore 第二个参数，应用中间件
const store = createStore(persistedReducer, applyMiddleware(thunk))
const persistor = persistStore(store)
export { store, persistor }
